package com.LC.DAO;

import com.LC.Entity.Member;
import org.apache.ibatis.annotations.*;

import java.util.Map;


@Mapper
public interface MemberDAO {
    
    @Select("select count(*) from t_member where regTime between STR_TO_DATE(#{beginDate},'%Y-%m-%d') and STR_TO_DATE(#{endDate},'%Y-%m-%d')")
    public int findNumberPerMonth(@Param("beginDate") String beginDate, @Param("endDate") String endDate);

    @Select("select count(*) from t_member where phoneNumber = #{PhoneNumber}")
    public int findMemberCount(String PhoneNumber);
    
    @Insert("insert into t_member values(null,#{fileNumber},#{name},#{sex},#{idCard},#{telephone},STR_TO_DATE(#{regTime},'%Y-%m-%d'),null,null,#{birthday},null)")
    @Options(useGeneratedKeys = true)
    public void addMember(Map map);
    
    @Select("select id from t_member where phoneNumber = #{telephone}")
    public int findMemberIdByTelephone(String telephone);
    
    @Select("select * from t_member where id = #{id}")
    public Member findMemberById(int id);
    
    @Select("select count(*) from t_member where fileNumber LIKE CONCAT('%',#{s},'%')")
    public Integer findFileNumberCount(String s);

    @Select("select count(*) from t_member where fileNumber = #{s}")
    public Integer findClearFileNumberCount(String s);
}
